**** CREATE VARIABLES FOR USE IN TABLES 1-3 ****

**** Make indicators from Geddes, Wright, Frantz (GWF) data ****
**** Generate continuous degree of personalism from GWF ****
generate gwf_personal = 2 if gwf_adjusted==8|gwf_adjusted==0
recode gwf_personal .= 1 if gwf_adjusted==5|gwf_adjusted==6|gwf_adjusted==7
recode gwf_personal .=0 if gwf_adjusted==1|gwf_adjusted==2|gwf_adjusted==3|gwf_adjusted==4|gwf_adjusted==9

*** Make dichotomous indicators out of gwf_adjusted ***
generate gwf_monarchy = 1 if gwf_adjusted==0
recode gwf_monarchy .=0 if gwf_adjusted~=. & gwf_adjusted~=0

generate gwf_military = 1 if gwf_adjusted==1|gwf_adjusted==2
recode gwf_military .=0 if gwf_adjusted~=. & (gwf_adjusted~=1|gwf_adjusted~=2)

generate gwf_party = 1 if gwf_adjusted==3|gwf_adjusted==9
recode gwf_party .=0 if gwf_adjusted~=. & (gwf_adjusted~=3|gwf_adjusted~=9)

generate gwf_personalist = 1 if gwf_adjusted==8
recode gwf_personalist .=0 if gwf_adjusted~=. & gwf_adjusted~=8


**** Make minimum, maximum, and average consolidation levels for each leader ****
sort hspell
by hspell: egen maxcons_median = max(xhatmedian)
by hspell: egen mincons_median = min(xhatmedian)
by hspell: egen avecons_median = mean(xhatmedian)



**** TABLE 1: ASSOCIATION BETWEEN OUR MEASURE AND EXISTING INDICATORS ****
**** Table 1, Columns 1-4: unit of analysis is leader-year ****
regress xhatmedian polconv
regress xhatmedian xconst
regress xhatmedian gwf_personal
regress xhatmedian gwf_monarchy gwf_personalist gwf_party gwf_military

**** Table 1, Columns 5-6: unit of analysis is leader ****
regress maxcons_median gwf_personal if flagh==1
regress maxcons_median gwf_monarchy gwf_personalist gwf_party gwf_military if flagh==1



**** TABLE 2: POWER CONSOLIDATION AND SUCCESSION IN SUB-SAHARAN AFRICAN EXAMPLES ****
**** Cameroon: Ahidjo ****
list leadername year mincons_median maxcons_median avecons_median succession if flagh==1 & hspell==31
**** Namibia: Nujoma ****
list leadername year mincons_median maxcons_median avecons_median succession if flagh==1 & hspell==503
**** Mozambique: Chissano ****
list leadername year mincons_median maxcons_median avecons_median succession if flagh==1 & hspell==289
**** Togo: Eyadema ****
list leadername year mincons_median maxcons_median avecons_median succession if flagh==1 & hspell==165



**** TABLE 3: DIFFERENCE IN POWER CONSOLIDATION LEVELS BY SUCCESSION OUTCOMES ****

**** Note that succession is coded as follows: 5 = unilateral, 4 = censored, 3 = constrained, 2 = vetoed, 1 = no choice ****
**** Work for Column 1 ****
**** Create average of average consolidation level during tenure by different succession outcomes ****
generate avemdfive = avecons_median if flagh==1 & succession==5
generate avemdthree = avecons_median if flagh==1 & succession==3
generate avemdtwo = avecons_median if flagh==1 & succession==2
generate avemdone = avecons_median if flagh==1 & succession==1
generate avemdtwothree = avecons_median if flagh==1 & (succession==2|succession==3)

**** Table 3, Column 1: Test of differences in mean consolidation level during tenure **** 
ttest avemdfive==avemdtwothree, unpaired welch
ttest avemdfive==avemdthree, unpaired welch
ttest avemdfive==avemdtwo, unpaired welch
ttest avemdfive==avemdone, unpaired welch

**** Work for Column 2 ****
**** Create average of maximum consolidation level during tenure by different succession outcomes **** 
generate maxmdfive = maxcons_median if flagh==1 & succession==5
generate maxmdthree = maxcons_median if flagh==1 & succession==3
generate maxmdtwo = maxcons_median if flagh==1 & succession==2
generate maxmdone = maxcons_median if flagh==1 & succession==1
generate maxmdtwothree = maxcons_median if flagh==1 & (succession==2|succession==3)

**** Table 3, Column 2: Test of differences in maximum consolidation level during tenure ****
ttest maxmdfive==maxmdtwothree, unpaired welch
ttest maxmdfive==maxmdthree, unpaired welch
ttest maxmdfive==maxmdtwo, unpaired welch
ttest maxmdfive==maxmdone, unpaired welch

**** Work for Column 3 ****
**** Create flag to mark for last year of leader's spell ****
sort hspell
by hspell: egen maxage = max(ageh)
generate endh = 1 if maxage==ageh
**** Create average of consolidation level in last year of tenure by different succession outcomes ****
generate xhatmdendfive = xhatmedian if endh==1 & succession==5
generate xhatmdendthree = xhatmedian if endh==1 & succession==3
generate xhatmdendtwo = xhatmedian if endh==1 & succession==2
generate xhatmdendone = xhatmedian if endh==1 & succession==1
generate xhatmdendtwothree = xhatmedian if endh==1 & (succession==2|succession==3)

**** Table 3, Column 3: Test of differences in consolidation level in last year of tenure ****
ttest xhatmdendfive==xhatmdendtwothree, unpaired welch
ttest xhatmdendfive==xhatmdendthree, unpaired welch
ttest xhatmdendfive==xhatmdendtwo, unpaired welch
ttest xhatmdendfive==xhatmdendone, unpaired welch
